#include <iostream>
class A {
	int m_a;
public:
	explicit A(int a=0) : m_a(a) {}
	A(const A& a) {
		std::cout << "copy constructor" << std::endl;
		m_a = a.m_a;
	}
	//1.not void, otherwise chaining is not allowed.
	//2.not A, otherwise copy construct and destructor are called
	A& operator= (const A& a) { 
		std::cout << "assignment" << std::endl;
		m_a = a.m_a;
		return *this;
	}
	~A(){ std::cout << "destructor" << std::endl; }

	int get() const {return m_a;}
};

int main()
{
	A a(12);
	A b,c;
	c=b=a;
	std::cout << "a: " << a.get() << std::endl;
	std::cout << "b: " << b.get() << std::endl;
	std::cout << "c: " << c.get() << std::endl;
}